home *** CD-ROM | disk | FTP | other *** search
/ Cream of the Crop 26 / Cream of the Crop 26.iso / program / qbsnip.zip / THEWOODS.BAS < prev    next >
BASIC Source File  |  1997-06-20  |  13KB  |  308 lines

  1. '_|_|_|   THEWOODS.BAS
  2. '_|_|_|   A simple game to demonstrate some basic principles.
  3. '_|_|_|   No warrantee or guarantee given or implied.
  4. '_|_|_|   PUBLIC DOMAIN   by Kurt Kuzba.  (6/19/1997)
  5.  
  6. TYPE character: Pname AS STRING * 32: hits AS LONG
  7.    magic AS LONG: strength AS LONG: gold AS LONG
  8.    Weapon AS INTEGER: experience AS LONG: END TYPE
  9. DIM SHARED Player AS character, Enemy AS character
  10. RANDOMIZE TIMER
  11. SCREEN 0: WIDTH 80, 25: COLOR 9,0: CLS: LOCATE 3
  12. LOCATE , 10: PRINT "Your goal is to gain 2,000 experience."
  13. LOCATE , 10: PRINT "Upon doing this, you will have won.   "
  14. LOCATE , 10: PRINT "It will NOT, however, be easy.        "
  15. LOCATE , 10: PRINT "You will meet many malevolent forces. "
  16. COLOR 11 : LOCATE 14, 1: INPUT "What is your name? ", plyr$
  17. IF plyr$ > "" THEN
  18.    DO: Player.Pname = plyr$: Player.hits = 30: Player.magic = 0
  19.       Player.strength = 0: Player.gold = 100: Player.Weapon = 0
  20.       Player.experience = 0: Gameplay
  21.       PRINT : PRINT "Would you like to play again (YN)? ";
  22.       DO: k$ = UCASE$(INKEY$): LOOP WHILE INSTR(" YN", k$) < 2
  23.       PRINT k$: LOOP WHILE k$ = "Y"
  24. END IF
  25. PRINT : PRINT "Goodbye, then...": PRINT "Hit any key to continue."
  26. WHILE INKEY$ > "": WEND: WHILE INKEY$ = "": WEND: SYSTEM
  27. SUB Armory : DIM price(1 TO 8) AS INTEGER
  28.    price(1) = 75: price(2) = 200: price(3) = 400: price(4) = 600
  29.    price(5) = 900: price(6) = 1500: price(7) = 2500: price(8) = 4000
  30.    DO: COLOR 10, 0: PRINT
  31.       PRINT " Would you like to Sell or Buy a weapon (S/B/Q)? ";
  32.       DO: k% = INSTR(" SBQ" + CHR$(13), UCASE$(INKEY$))
  33.       LOOP WHILE k% < 2
  34.       PRINT MID$(" SBQQ", k%, 1): PRINT
  35.       SELECT CASE k%
  36.          CASE 2: money% = Player.Weapon * 30
  37.             IF money% = 0 THEN
  38.                PRINT " You cannot sell your hands here, friend!"
  39.             ELSE
  40.                PRINT " I will give you"; money%; "gold for your ";
  41.                PRINT Weapon$(Player.Weapon)
  42.                PRINT " Is it a deal (Y/N)? ";
  43.                DO: k% = INSTR(" YN", UCASE$(INKEY$))
  44.                LOOP WHILE k% < 2
  45.                PRINT MID$(" YN", k%, 1): PRINT
  46.                IF k% = 2 THEN
  47.                   Player.gold = Player.gold + money%
  48.                   Player.Weapon = 0
  49.                END IF
  50.             END IF
  51.          CASE 3: PRINT "--==**[  PRICES  ]**==--"
  52.             FOR t% = 1 TO 8: PRINT STR$(t%); "->";
  53.                PRINT LEFT$(STR$(price(t%)) + "    ", 6);
  54.                PRINT Weapon$(t%): NEXT
  55.             PRINT " Hit ENTER to buy nothing"
  56.             PRINT " You have"; Player.gold; "gold."
  57.             PRINT "Which would you buy (1-8)? ";
  58.             DO: k% = INSTR(" 12345678" + CHR$(13), UCASE$(INKEY$))
  59.             LOOP WHILE k% < 2
  60.             k% = k% - 1: PRINT MID$("12345678", k%, 1)
  61.             IF k% < 9 THEN
  62.                money% = k% * 90
  63.                IF money% > Player.gold THEN
  64.                   PRINT " You can not afford "; Weapon$(k%)
  65.                ELSE
  66.                   PRINT " Sold! I hope that "; Weapon$(k%)
  67.                   PRINT " will serve you well."
  68.                   Player.gold = Player.gold - money%
  69.                   Player.Weapon = k%
  70.                END IF
  71.             END IF
  72.          CASE 4, 5: EXIT SUB
  73.       END SELECT
  74.    LOOP: END SUB
  75.  
  76. SUB FightMonster : level% = GetLevel%(Player.experience)
  77.    MakeEnemy level%: menu% = 1
  78.    WHILE (Player.hits > 0) AND (Enemy.hits > 0)
  79.       COLOR 4, 0: PRINT
  80.       IF menu% > 0 THEN
  81.          PRINT " F-> Fight": PRINT " R-> Run Away"
  82.          PRINT " S-> Surrender": PRINT " Y-> Your Stats"
  83.          PRINT " V-> View Enemy"
  84.       END IF
  85.       COLOR 15, 0: PRINT Player.hits; : COLOR 5, 0: PRINT Player.Pname
  86.       COLOR 15, 0: PRINT Enemy.hits; : COLOR 5, 0: PRINT Enemy.Pname
  87.       COLOR 4, 0: PRINT " [ F : R : S : Y : V : ? ]=> ";
  88.       DO: k% = INSTR(" FRSYV?", UCASE$(INKEY$)): LOOP WHILE k% < 2
  89.       PRINT MID$(" FRSYV?", k%, 1)
  90.       level% = GetLevel%(Player.experience)
  91.       SELECT CASE k%
  92.          CASE 2
  93.             PlayerAtt! = 1 + Player.Weapon
  94.             PlayerAtt! = PlayerAtt! * (1 + (Player.strength / 10))
  95.             PlayerAtt! = 5 + (RND * PlayerAtt! * 5 * level%)
  96.             PlayerDef! = 1 + (Player.strength / 100)
  97.             EnemyAtt! = Enemy.Weapon * (1 + (Enemy.strength / 10))
  98.             EnemyDef! = 1 + (Enemy.strength / 100)
  99.             IF RND > .5 THEN
  100.                PRINT " You move fast and hit first."
  101.                hits% = PlayerAtt! / EnemyDef!
  102.                IF hits% > Enemy.hits THEN hits% = Enemy.hits
  103.                Enemy.hits = Enemy.hits - hits%
  104.                PRINT " You hit for"; hits%; "points."
  105.                Player.experience = Player.experience + hits%
  106.                IF Enemy.hits > 0 THEN
  107.                   hits% = EnemyAtt! / PlayerDef!
  108.                   IF hits% > Player.hits THEN hits% = Player.hits
  109.                   Player.hits = Player.hits - hits%
  110.                   PRINT " You are hit for"; hits%; "points."
  111.                END IF
  112.             ELSE
  113.                PRINT " You move slow and get hit first."
  114.                hits% = EnemyAtt! / PlayerDef!
  115.                IF hits% > Player.hits THEN hits% = Player.hits
  116.                Player.hits = Player.hits - hits%
  117.                PRINT " You are hit for"; hits%; "points."
  118.                IF Player.hits > 0 THEN
  119.                   hits% = PlayerAtt! / EnemyDef!
  120.                   IF hits% > Enemy.hits THEN hits% = Enemy.hits
  121.                   Enemy.hits = Enemy.hits - hits%
  122.                   Player.experience = Player.experience + hits%
  123.                   PRINT " You hit for"; hits%; "points."
  124.                END IF
  125.             END IF
  126.             IF Enemy.hits = 0 THEN
  127.                PRINT " You have defeated the "; Enemy.Pname
  128.                Player.magic = Player.magic + Enemy.magic \ 10
  129.                Player.gold = Player.gold + Enemy.gold
  130.             END IF
  131.             IF Player.hits = 0 THEN
  132.                PRINT " You were defeated by a "; Enemy.Pname
  133.             END IF
  134.          CASE 3:
  135.             PRINT " You manage to escape, but all your strength"
  136.             PRINT " and magic are lost, and some experience points."
  137.             Player.magic = 0: Player.strength = 0
  138.             Player.experience = Player.experience * .9
  139.             EXIT SUB
  140.          CASE 4:
  141.             PRINT " You give all your gold to the "; Enemy.Pname
  142.             Player.gold = 0: EXIT SUB
  143.          CASE 5: Stats Player
  144.          CASE 6: Stats Enemy
  145.          CASE 7: menu% = 1
  146.       END SELECT: WEND: END SUB
  147.  
  148. SUB Gameplay : menu% = 1: Stats Player
  149.    DO
  150.       IF Player.hits > 0 THEN
  151.          PRINT
  152.          IF menu% > 0 THEN
  153.             COLOR 15, 0: PRINT " W->  Woods": PRINT " H->  Healer"
  154.             PRINT " A->  Armory": PRINT " S->  Your Stats"
  155.             PRINT " Q->  Quit Game"
  156.          END IF: COLOR 11, 0: LOCATE , , 0: menu% = 0
  157.          PRINT " [ W : H : A : S : Q : ? ]=> ";
  158.          DO: k% = INSTR(" WHASQ?", UCASE$(INKEY$)): LOOP WHILE k% < 2
  159.          PRINT MID$(" WHASQ", k%, 1)
  160.          SELECT CASE k%
  161.             CASE 2: Woods
  162.             CASE 3: Healer
  163.             CASE 4: Armory
  164.             CASE 5: Stats Player
  165.             CASE 6: PRINT : PRINT "Leave the Woods (YN)? ";
  166.                DO: k$ = UCASE$(INKEY$)
  167.                LOOP WHILE INSTR(" YN", k$) < 2
  168.                PRINT k$: IF k$ = "Y" THEN EXIT DO
  169.             CASE 7: menu% = 1
  170.          END SELECT
  171.       ELSE
  172.          IF Player.experience < 2000 THEN
  173.             PRINT "Sorry... You have perished in battle."
  174.             FOR t% = 200 TO 150 STEP -1: SOUND t%, .1: NEXT
  175.          ELSE
  176.             PRINT "You have defeated all enemies! You WIN!!"
  177.             FOR t% = 100 TO 999 STEP 10: SOUND t%, .03: NEXT
  178.             FOR t% = 1000 TO 500 STEP -10: SOUND t%, .03: NEXT
  179.          END IF: PRINT "You had"; Player.experience; "points."
  180.          EXIT DO
  181.       END IF: LOOP: END SUB
  182. FUNCTION GetLevel% (e&)
  183.    SELECT CASE e&
  184.       CASE IS < 100: level% = 1
  185.       CASE 101 TO 500: level% = 2
  186.       CASE ELSE: level% = 3
  187.    END SELECT: GetLevel% = level%: END FUNCTION
  188. SUB Healer : Totalhits% = Player.experience \ 10 + 30
  189.    ToHeal% = Totalhits% - Player.hits
  190.    IF ToHeal% <= 0 THEN
  191.       PRINT " You do not require healing!"; CHR$(7)
  192.    ELSE
  193.       PRINT " Each point costs 3 gold to heal."
  194.       PRINT " You can afford to heal"; Player.gold \ 3; "hit points."
  195.       PRINT " You need to heal"; ToHeal%
  196.       INPUT " How many would you heal? ", heal%
  197.       IF heal% > ToHeal% THEN heal% = ToHeal%
  198.       IF heal% > (Player.gold \ 3) THEN heal% = Player.gold \ 3
  199.       Player.hits = Player.hits + heal%
  200.       Player.gold = Player.gold - (heal% * 3)
  201.       PRINT " I have healed you for"; heal%; "hit points."
  202.    END IF: END SUB
  203. SUB MakeEnemy (l%) : DIM EN(1 TO 3) AS STRING, EP(1 TO 3) AS STRING
  204.    EP(1) = "Ferocious ": EP(2) = "Snarling ": EP(3) = "Evil "
  205.    SELECT CASE l%
  206.       CASE 1: EN(1) = "Squirrel": EN(2) = "Bunny": EN(3) = "Hedgehog"
  207.       CASE 2: EN(1) = "Bear": EN(2) = "Boar": EN(3) = "Troll"
  208.       CASE 3: EN(1) = "Demon": EN(2) = "Dragon": EN(3) = "Wizard"
  209.    END SELECT
  210.    Enemy.Pname = EP(l%) + EN(RND * 2 + 1)
  211.    Enemy.hits = ((RND * 10 + 20) * l%)
  212.    Enemy.magic = ((RND * 10 + 10) * l%)
  213.    Enemy.strength = ((RND * 10 + 10) * l%)
  214.    Enemy.gold = ((RND * 100 + 100) * l%)
  215.    Enemy.Weapon = (RND * 2 + l% * 2): END SUB
  216.  
  217. SUB Stats (P AS character) : COLOR 15, 0: PRINT
  218.    COLOR 15, 1: PRINT " Name       : "; P.Pname;
  219.    COLOR 15, 0: PRINT : COLOR 15, 1: PRINT " Hits       :";
  220.    PRINT LEFT$(STR$(P.hits) + SPACE$(32), 33);
  221.    COLOR 15, 0: PRINT : COLOR 15, 1: PRINT " Magic      :";
  222.    PRINT LEFT$(STR$(P.magic) + SPACE$(32), 33);
  223.    COLOR 15, 0: PRINT : COLOR 15, 1: PRINT " Strength   :";
  224.    PRINT LEFT$(STR$(P.strength) + SPACE$(32), 33);
  225.    COLOR 15, 0: PRINT : COLOR 15, 1: PRINT " Gold       :";
  226.    PRINT LEFT$(STR$(P.gold) + SPACE$(32), 33);
  227.    COLOR 15, 0: PRINT : COLOR 15, 1: PRINT " Weapon     : ";
  228.    PRINT LEFT$(Weapon$(P.Weapon) + SPACE$(32), 32);
  229.    COLOR 15, 0: PRINT : COLOR 15, 1: PRINT " Experience :";
  230.    PRINT LEFT$(STR$(P.experience) + SPACE$(32), 33);
  231.    COLOR 15, 0: PRINT : END SUB
  232. SUB UseMagic : COLOR 12, 0: PRINT : PRINT : menu% = 1
  233.    DO
  234.       IF menu% <> 0 THEN
  235.          PRINT " H-> Healing Spell   (4 magic)"
  236.          PRINT " S-> Strength Spell  (9 magic)"
  237.          PRINT " Q-> Quit this menu"
  238.       END IF: PRINT " You have"; Player.magic; "spell points."
  239.       menu% = 0: PRINT " [ H : S : Q : ? ]=> ";
  240.       DO: k% = INSTR(" HSQ?" + CHR$(13), UCASE$(INKEY$))
  241.       LOOP WHILE k% < 2: PRINT MID$(" CST?", k%, 1): PRINT
  242.       SELECT CASE k%
  243.          CASE 2
  244.             IF Player.magic < 4 THEN
  245.                PRINT " You haven't the magic!"
  246.             ELSE
  247.                m% = 1 + RND * 9
  248.                Player.magic = Player.magic - 4
  249.                Player.hits = Player.hits + m%
  250.                PRINT " Your spell yields"; m%; "hits."
  251.             END IF
  252.          CASE 3
  253.             IF Player.magic < 9 THEN
  254.                PRINT " You haven't the magic!"
  255.             ELSE
  256.                m% = 1 + RND * 9
  257.                Player.magic = Player.magic - 9
  258.                Player.strength = Player.strength + m%
  259.                PRINT " Your spell yields"; m%; "strength."
  260.             END IF
  261.          CASE 4, 6: EXIT SUB
  262.          CASE 5: menu% = 1
  263.       END SELECT: LOOP: END SUB
  264. SUB WalkInWoods
  265.    SELECT CASE (RND * 99)
  266.       CASE 0 TO 9: Player.gold = Player.gold + 1
  267.          COLOR 14, 0: PRINT "You found a piece of gold!"
  268.       CASE 10 TO 19: Player.magic = Player.magic + 1
  269.          COLOR 13, 0: PRINT "A faerie gives you one magic!"
  270.       CASE 20 TO 29: m% = 1 + RND * 9
  271.          Player.hits = Player.hits + m%
  272.          COLOR 9, 0: PRINT "A friendly Elf heals"; m%; "hit";
  273.          IF m% = 1 THEN PRINT "!":  ELSE PRINT "s!"
  274.       CASE 30 TO 89
  275.          COLOR 6, 0: PRINT "The path continues before you."
  276.       CASE ELSE: FightMonster
  277.    END SELECT: END SUB
  278. FUNCTION Weapon$ (w%)
  279.    SELECT CASE w%
  280.       CASE 0: Weapon$ = "Your Bare Hands"
  281.       CASE 1: Weapon$ = "A Stick"
  282.       CASE 2: Weapon$ = "A Quarterstaff"
  283.       CASE 3: Weapon$ = "A Small Knife"
  284.       CASE 4: Weapon$ = "A Big Knife"
  285.       CASE 5: Weapon$ = "A Machete"
  286.       CASE 6: Weapon$ = "A Shortsword"
  287.       CASE 7: Weapon$ = "A Longsword"
  288.       CASE 8: Weapon$ = "A Two-Handed Sword"
  289.    END SELECT: END FUNCTION
  290. SUB Woods : menu% = 1
  291.    DO: level% = GetLevel%(Player.experience)
  292.       IF Player.experience > 2000 THEN Player.hits = 0
  293.       COLOR 2, 0: PRINT : IF Player.hits = 0 THEN EXIT SUB
  294.       IF menu% <> 0 THEN
  295.          PRINT " C-> Continue": PRINT " T-> Go to Town"
  296.          PRINT " S-> Cast a Spell": PRINT " Y-> Your Stats"
  297.       END IF: menu% = 0: PRINT " [ C : S : T : Y : ? ]=> ";
  298.       DO: k% = INSTR(" CTSY?", UCASE$(INKEY$)): LOOP WHILE k% < 2
  299.       PRINT MID$(" CSTY?", k%, 1)
  300.       SELECT CASE k%
  301.          CASE 2: WalkInWoods
  302.          CASE 3: EXIT SUB
  303.          CASE 4: UseMagic
  304.          CASE 5: Stats Player
  305.          CASE 6: menu% = 1
  306.       END SELECT: LOOP: END SUB
  307.  
  308.